package com.lzx.article.controller;

import com.lzx.article.entity.vo.ArticleParams;
import com.lzx.article.service.ArticlesService;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lzx
 * @since 2023-01-11
 */
@RestController
@RequestMapping("/article/articles")
public class ArticlesController {
    @Resource
    private ArticlesService articlesService;

    //获取所有文章
    @GetMapping("/getArticleList/{current}/{size}")
    public R getArticleList(@PathVariable int current, @PathVariable int size) {
        return articlesService.getArticleList(current, size);
    }

    //搜索
    @PostMapping("/searchArticle")
    public R searchArticle(@RequestBody ArticleParams articleParams) {
        return articlesService.searchArticle(articleParams);
    }

    //导出
    @GetMapping("/exportArticle")
    public void exportArticle(HttpServletResponse response) {
        articlesService.exportArticle(response);
    }
}
